#pragma once

#include <stdio.h>

void Print(int* array, int size)
{
  for(int i = 0; i < size; i++){
    printf("%d ", array[i]);
  }
  printf("\n");
}

void Swap(int* pa1, int* pa2)
{
  int tmp = *pa1;
  *pa1 = *pa2;
  *pa2 = tmp;
}

void ShellSort(int* array, int size)
{
  int gap = size;
  while(gap > 1){
    gap = gap / 3 + 1;
    for(int i = gap; i < size; i ++){
      int end = i - gap;
      while(end >= 0){
        if(array[end] > array[end + gap]) Swap(&array[end], &array[end + gap]);
        else break;
        end -= gap;
      }
    }
  }
}
